package com.edgclub.edg.utils.GlideUtil;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.edgclub.edg.R;

/**
 * 图片下载管理器
 * 
 * @author eric
 * 
 */
public class ImageLoaderClient {

	private Context mContext;

	public ImageLoaderClient(Context mContext) {
		this.mContext = mContext;
	}



	public void loadBitmapFromGidleRound(String uri, ImageView imageView) {
		try {
			if (uri.startsWith("http://")){
				if (!uri.contains("x-oss-process")){
					uri +=  "?x-oss-process=image/format,webp";
				} else {
					uri += "/format,webp";
				}
			}
			Glide.with(mContext).load(uri).centerCrop()
					.error(R.drawable.ic_gz_default_img2)
					.placeholder(R.drawable.ic_gz_default_img2).crossFade()
					.transform(new RoundTransform(mContext)).into(imageView);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void loadBitmapFromGidleFillet(String uri, ImageView imageView) {
		try {
			Glide.with(mContext).load(uri).centerCrop()
					.error(R.drawable.ic_gz_default_img2)
					.placeholder(R.drawable.ic_gz_default_img2).crossFade()
					.transform(new FilletTransform(mContext)).into(imageView);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}



}
